package com.whmskj.xjlhsc.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.entity.Sb02EquipmentCounterAccount;
import com.whmskj.xjlhsc.service.MonitorService;
import com.whmskj.xjlhsc.service.Sb02EquipmentCounterAccountService;
import com.whmskj.xjlhsc.service.dto.RealInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 运行监控
 */
@RestController
@RequestMapping("/api/jt/monitor")
@SaIgnore
public class MonitorController {

    @Autowired
    private Sb02EquipmentCounterAccountService service;
    @Autowired
    private MonitorService monitorService;


    /**
     * 设备台账
     * @return
     */
    @GetMapping("/findList")
    public Result findList() {
        Map<String,List<Sb02EquipmentCounterAccount>> result = service.findEquipmentList();
        return Result.success(result);
    }

    /**
     * 总览
     * @return
     */
    @GetMapping("/findZl")
    public Result findZl(int id) {
        List<Object> result = service.findZl(id);
        return Result.success(result);
    }

    /**
     * 实时信息
     * @return
     */
    @GetMapping("/findRealInfo")
    @SaIgnore
    public Result findRealInfo(@RequestParam Integer deviceId) {
        RealInfoDto result = monitorService.getDeviceRealTimeInfo(deviceId);
        return Result.success(result);
    }

    /**
     * 实时信息-维护保养
     * @return
     */
    @GetMapping("/findRealInfoWbList")
    public Result findRealInfoWbList(int id) {
        Page<Object> result = service.findRealInfoWbList(id);
        return Result.success(result);
    }

    /**
     * 实时信息-停车记录
     * @return
     */
    @GetMapping("/findRealInfoStopList")
    public Result findRealInfoStopList(int id) {
        Page<Object> result = service.findRealInfoStopList(id);
        return Result.success(result);
    }

    /**
     * 实时信息-产能信息
     * @return
     */
    @GetMapping("/findRealInfoCnList")
    public Result findRealInfoCnList(int id) {
        Page<Object> result = service.findRealInfoCnList(id);
        return Result.success(result);
    }

    /**
     * 机台参数
     * @return
     */
    @GetMapping("/findParamInfo")
    public Result findParamInfo(int id) {
        Object result = service.findParamInfo(id);
        return Result.success(result);
    }

    /**
     * 电能数据
     * @return
     */
    @GetMapping("/getPowerInfo")
    public Result findDnInfo(@RequestParam Integer deviceId) {
        return Result.success(monitorService.findDnInfo(deviceId));
    }

    /**
     * 机台对比
     * @return
     */
    @GetMapping("/findJtdbInfo")
    public Result findJtdbInfo(String ids, @RequestParam(required = false) String start, @RequestParam(required = false) String end) {
        Object result = service.findJtdbInfo(ids,start,end);
        return Result.success(result);
    }

    /**
     * 专备件
     * @return
     */
    @GetMapping("/findZbjInfo")
    public Result findZbjInfo(int id) {
        Page<Object> result = service.findZbjInfo(id);
        return Result.success(result);
    }

    /**
     * 保养维护
     * @return
     */
    @GetMapping("/findWbTopInfo")
    public Result findWbInfo(int id) {
        Object result = service.findWbTopInfo(id);
        return Result.success(result);
    }

    /**
     * 保养维护历史
     * @return
     */
    @GetMapping("/findWbHistoryInfo")
    public Result findWbInfo(int id,@RequestParam(required = false)String xm,
                             @RequestParam(required = false)Boolean xstp) {
        Page<Object> result = service.findWbHistoryInfo(id,xm);
        return Result.success(result);
    }

    @GetMapping("/humidification-room-real-data")
    @SaIgnore
    public Result getHumidificationRoomRealData(String area) {
        return Result.success(monitorService.getHumidificationRoomRealData(area));
    }
}
